package com.itranswarp.bitcoin.p2p.message;

import static org.junit.Assert.*;

import java.io.IOException;

import org.junit.Test;

import com.itranswarp.bitcoin.util.HashUtils;

public class GetHeadersMessageTest {

	@Test
	public void testNewGetHeadersMessageWithPayload() throws IOException {
		GetHeadersMessage msg = new GetHeadersMessage(DATA);
		assertNotNull(msg);
		assertEquals(30, msg.hashes.length);
		for (int i = 0; i < msg.hashes.length; i++) {
			System.out.println(HashUtils.toHexStringAsLittleEndian(msg.hashes[i]));
		}
		assertEquals("0000000000000000000000000000000000000000000000000000000000000000",
				HashUtils.toHexString(msg.hashStop));
	}

	static final byte[] DATA = { 114, 17, 1, 0, 30, -31, -6, 54, 13, -84, -38, 110, -44, -20, -39, -46, 56, 94, -68,
			126, -58, 51, -79, 65, 51, 118, 20, -53, 2, 0, 0, 0, 0, 0, 0, 0, 0, -98, -76, -25, 60, 35, 74, -35, 125,
			-107, -9, -89, -107, -21, 7, -110, -107, 68, -92, -119, 114, 78, -112, 84, 4, 0, 0, 0, 0, 0, 0, 0, 0, -13,
			-14, 88, 73, -105, -96, -91, -47, 23, 23, 5, -64, 1, -86, 27, -46, 68, 26, 106, -69, 37, -5, 9, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 58, -87, -42, 88, 5, -81, -96, -32, 50, -74, 98, -127, 8, -52, 115, 4, -66, 35, 83, 31, 7,
			109, 18, 2, 0, 0, 0, 0, 0, 0, 0, 0, 57, 78, -88, 125, 125, -31, -112, -113, 2, -43, 121, 112, -47, -19, -17,
			-99, -115, -127, 10, 123, -113, -121, 120, 3, 0, 0, 0, 0, 0, 0, 0, 0, 28, 56, -109, -33, -102, 98, -56, -2,
			42, 88, 5, 25, 44, 116, 0, 91, -7, -43, -122, -72, -75, 108, -95, 1, 0, 0, 0, 0, 0, 0, 0, 0, -5, 89, 72,
			-126, -93, 101, 44, 60, -126, 22, -7, 96, 73, -57, 19, -70, -111, 67, -122, 95, 64, -69, 64, 2, 0, 0, 0, 0,
			0, 0, 0, 0, 50, 72, 7, -83, -28, 44, 84, 15, 37, 12, 115, 50, -80, 99, 17, 13, 114, -61, 111, -14, 60, 6,
			65, 1, 0, 0, 0, 0, 0, 0, 0, 0, 91, -121, -117, -94, -114, 96, -72, 37, -38, 41, 20, 85, 102, 52, 72, 38,
			-50, 25, -59, 61, -15, 109, -44, 2, 0, 0, 0, 0, 0, 0, 0, 0, -32, -50, -29, 6, 26, -109, -112, 57, 21, 21,
			-116, -108, -56, -3, 14, -48, 92, -63, -120, -34, 58, 3, 85, 4, 0, 0, 0, 0, 0, 0, 0, 0, -114, 111, 58, -5,
			-90, 109, 18, -1, 32, 60, -68, 111, -112, -3, 29, 8, 90, 44, 11, 44, -108, -76, 95, 1, 0, 0, 0, 0, 0, 0, 0,
			0, -99, 22, 104, 19, -46, -48, 13, 54, -93, 113, 83, -28, 28, -39, 50, -103, 55, -86, -50, 28, -122, -110,
			-91, 2, 0, 0, 0, 0, 0, 0, 0, 0, -53, 74, -119, 11, 14, 96, 33, 94, -54, -9, -117, -30, 26, -14, -72, -105,
			-33, 119, 78, -3, -112, 63, -83, 3, 0, 0, 0, 0, 0, 0, 0, 0, 44, 26, -13, 103, 33, -8, 106, 64, -39, 113, 29,
			102, -113, 75, 19, 43, -29, -56, -12, 123, -41, 66, 81, 1, 0, 0, 0, 0, 0, 0, 0, 0, -82, -2, -71, -69, 114,
			66, 84, -35, 55, 74, 47, -8, -79, -79, -68, 51, -76, -110, -114, 114, -41, -116, 115, 1, 0, 0, 0, 0, 0, 0,
			0, 0, 47, -12, 14, 12, -43, -40, 42, 82, 114, -28, -72, 103, 109, -114, -71, -75, 6, 119, -98, 72, -108,
			-25, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, -36, -108, -7, 87, -54, 88, -24, -70, -38, -37, -119, 13, -3, 118, 98,
			-21, 74, -3, 118, -32, 28, 123, -40, 3, 0, 0, 0, 0, 0, 0, 0, 0, 121, 97, -88, -75, 99, -15, 111, 3, -59, 43,
			-20, -8, -70, 86, -17, 95, 92, 94, 55, 7, -27, 53, 122, 3, 0, 0, 0, 0, 0, 0, 0, 0, 27, -5, -63, 22, 16,
			-117, 61, -93, -118, -33, 120, -41, 28, -74, 8, 62, 114, 82, 34, 63, 17, 47, -124, 2, 0, 0, 0, 0, 0, 0, 0,
			0, -34, -60, -34, 112, -116, -94, 99, 71, 102, 23, -37, 101, 23, -86, -48, -37, 74, -53, 71, 66, -37, 67,
			27, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 83, -48, -38, -40, -120, 93, -123, 66, -15, -24, -28, 80, -50, -35, -56,
			-45, -74, -26, 41, -72, -8, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, -53, -7, 28, -20, 90, -81, 86, -121, -115, -88,
			-107, -78, -17, -107, -22, 120, 39, 64, -126, 50, 105, 84, -95, 3, 0, 0, 0, 0, 0, 0, 0, 0, 30, -46, -91,
			-29, -15, 4, 1, 63, 12, 81, -17, 63, -55, 126, 54, 15, -36, -7, -30, 112, -24, -79, 85, 2, 0, 0, 0, 0, 0, 0,
			0, 0, 127, -44, -48, -24, 112, 37, 90, 104, -117, 98, 17, 85, -54, 87, 73, -77, 66, -75, -54, 127, -125,
			-68, -54, 1, 0, 0, 0, 0, 0, 0, 0, 0, -76, -12, -94, 27, -95, -82, -21, -37, 52, 111, -108, 87, 90, -39, 5,
			82, 118, 40, -21, -61, 66, -11, 38, 3, 0, 0, 0, 0, 0, 0, 0, 0, 108, 50, 25, -117, 29, -105, -80, 92, 51, 61,
			8, 46, 23, -94, 61, 26, -36, -81, 114, 72, -25, 120, 124, 0, 0, 0, 0, 0, 0, 0, 0, 0, -3, -98, -103, 25, 118,
			-41, 59, -97, -94, 101, 108, -97, -98, -89, 90, -11, -117, -115, -17, 7, -112, 69, -44, 5, 0, 0, 0, 0, 0, 0,
			0, 0, -127, 65, 63, -20, 29, -24, -89, -52, 42, -12, 21, 26, -81, 105, 55, 96, 107, -26, -117, 90, -48, -71,
			-22, 66, 0, 0, 0, 0, 0, 0, 0, 0, -1, 57, 78, -72, -56, 36, -95, -53, -43, -99, -57, -5, -30, 46, -108, -28,
			-47, 114, -18, 3, -101, -22, -124, 83, 9, 0, 0, 0, 0, 0, 0, 0, 111, -30, -116, 10, -74, -15, -77, 114, -63,
			-90, -94, 70, -82, 99, -9, 79, -109, 30, -125, 101, -31, 90, 8, -100, 104, -42, 25, 0, 0, 0, 0, 0, 0, 0, 0,
			0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
}
